﻿#region Imports
using System;
using System.Drawing;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using CheckerWPF.Utils;
#endregion

namespace CheckerWPF.Converters
{
    public class CheckAlignmentConverter : IValueConverter
    {
        #region Converters
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility visibility = Visibility.Collapsed;
            bool vis = false;

            if (Utilities.IsContentAlignment(value))
            {
                ContentAlignment align = (ContentAlignment)value;
                align = Utilities.GetOnlyLR(align, Utilities.right);

                ContentAlignment? chkref = null;
                switch (System.Convert.ToString(parameter))
                {
                    case "L":
                        chkref = Utilities.left;
                        break;

                    case "R":
                    default:
                        chkref = Utilities.right;
                        break;
                }

                vis = (align == chkref);
            }

            if (vis) visibility = Visibility.Visible;
            return visibility;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return new NotImplementedException();
        }
        #endregion
    }
}
